package com.explorati.design_pattern.behavior.interpreter;

/**
 * 非终结符表达式(Nonterminal Expression)角色：该角色是一个具体角色，文法中的每一条规则都对应一个非终结表达式
 * 
 * @author explorati
 *
 */
public class AddInterpreter implements Interpreter {

	private Interpreter firstExpression, secondExpression;

	public AddInterpreter(Interpreter firstExpression, Interpreter secondExpression) {
		this.firstExpression = firstExpression;
		this.secondExpression = secondExpression;
	}

	@Override
	public int interpret() {
		return this.firstExpression.interpret() + this.secondExpression.interpret();
	}

	@Override
	public String toString() {
		return "+";
	}

}
